<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
	<title>
	</title>
	<meta charset="utf-8">
	<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<link rel="stylesheet" href="css/ui-img.css">
	<link rel="stylesheet" href="css/ui-res.css">
	<link rel="stylesheet" href="css/ui-list.css">
	<link rel="stylesheet" href="css/ui-base.css">
	<link rel="stylesheet" href="css/ui-box.css">
	<link rel="stylesheet" href="css/ui-color.css">
	<link rel="stylesheet" href="css/style.css">
	<script src="js/zy_control.js"></script>
	<script src="js/zy_click.js"></script>
	<script src="js/zy_json.js"></script>
	<script src="js/zy_tmpl.js"></script>
	<script src="js/zy_anim.js"></script>
	<script src="js/dis_control.js"></script>
	<script src="js/config.js"></script>
	<script>
	</script>
</head>
<body class="um-vp" ontouchstart>
	<!--最新帖子-->
	<div class="" id="page1">
		<div></div>
	</div>
</body>
<script>
zy_init();
var params = getStorJson('params');
var view = params.view;
var curpage = 1;
var totpage = 1;
var upt = '';
var update = {};
var cContent = $$('page1');
var uid = '';
if(view=='other') uid = params.uid;
else uid = getstorage('UID');
var updated = 0;
window.uexOnload=function(type)
{
	if(!type){
		setPageBounce(downcb, upcb);
		loadList('', '1');
		if(updated) loadList('', '');
	}
}
function downcb(){
	upt = '0';
	update['0'] = 1;
	loadList('', '');
}
function upcb(){
	if (curpage < totpage) {
		upt = '1';
		update['1'] = 1;
		loadList(curpage + 1, '');
	}
	else resetBV('1');
}

function loadList(pn, flag){
	var url = '';
	
	if(view=='thread') url =newest_url+'&mod=thread&page='+pn;
	else if(view=='reply') url = newest_url+'&mod=reply&page='+pn;
	else url = home_url + "&mod=space&do=thread&uid=" + uid + '&type=thread'+'&page=' + pn; //if(view=='myreply')

	logs('forum_list-->loadList()-->url='+url);
	if(url){
		updated = checkKey(url);
		if(!updated) uexWindow.toast('1','5','更新中...',"");
		var f = pn?'':'1';
		$.getJSON(url, getJsonCallback, 'json', getJsonErr, 'POST', '', flag, f);
	}
}
function getJsonCallback(json){
	uexWindow.closeToast();
	resetBV('0');
	resetBV('1');
		
	if (json) {
		if (Int(json.status)<1) {
				uexWindow.toast('0','5',json.message,2000);
				return;
			}
			
		var list = json.newThread || json.newReply || json.list;
		var length = zy_tmpl_count(list);

		if(list && list[0]){
			//var id0 = 0;
			//var id1 = list[0].tid;
			//if(cContent && cContent.children[0] && cContent.children[0].children[0]) id0=cContent.children[0].children[0].id;
			//logs('id0='+id0+', id1='+id1);
			//if(id0==id1) return;
		}
		
		var tmpl = '';
		if (view == 'thread') {
			tmpl = '<li ontouchstart="zy_touch(\'onbg\')" onclick="go2new5(${tid}, ${authorid});" class="uc-n ubb ub b-gra t-bla ub-ac lis" id="${tid}">' +
			'<div class="ub-f1 ub ub-ver">' +
			'<div class="ulev0 ut-s">${subject}</div>' +
			'<div class="ulev-1 umh3 t-gra umar-t">${message}</div>' +
			'<div class="ub ub-ac t-gra ulev-2 umar-t">' +
			'<div class="umh2 umw2 ub-img5 im3 lpic ub-posl"></div> ' +
			'${replies}' +
			'<div class="umh2 umw2 ub-img5 im4 lpicl lpic ub-posl"></div>' +
			'<div class="ub-f1">${views}</div>' +
			'<div class="umh2 umw2 ub-img5 im5 lpicl lpic"></div>' +
			'${dateline}' +
			'</div>' +
			'</div>' +
			'<div class="res8 lis-sw ub-img4"></div>' +
			'</li><li class="ubt1"></li>';
		}
		else if(view=='reply'){
			tmpl = '<li ontouchstart="zy_touch(\'onbg\')" onclick="go2new5(${tid}, ${authorid});" class="uc-n ubb ub b-gra t-bla ub-ac lis" id="${tid}">' +
			'<div class="ub-f1 ub ub-ver">	' +
			'<div class="ulev0 ut-s">${subject}</div>	' +
			'<div class="ulev-1 umh3 t-gra umar-t ut-s"><span class="t-blu1">${lastposter}</span><span class="lpicl lpic2">回复</span><span>${message}</span></div>' +
			'<div class="ub ub-ac t-gra ulev-2 umar-t"> ' +
			'<div class="ub-f1"></div>' +
			'<div class="umh2 umw2 ub-img5 im5 lpic"></div>' +
			'${lastpost}' +
			'</div>' +
			'</div>' +
			'<div class="res8 lis-sw ub-img4"></div> ' +
			'</li><li class="ubt1"></li>';
		}
		else{
			tmpl = '<li ontouchstart="zy_touch(\'onbg\')" onclick="go2new5(${tid}, ${authorid});" class="uc-n ubb ub b-gra t-bla ub-ac lis" id="${tid}">'
				 		+'<div class="ub-f1 ub ub-ver">'	 
				 	    	+'<div class="ulev0 ut-s">${subject}</div>	'	    
				    		+'<div class="ulev-1 umh3 t-gra umar-t">版块：${forumname}</div>' 
				 	    	+'<div class="ub ub-ac t-gra ulev-2 umar-t">'
				 		    	+'<div class="umh2 umw2 ub-img5 im3 lpic"></div>'
				 		    	+'${replies}'
				 		    	+'<div class="umh2 umw2 ub-img5 im4 lpicl lpic"></div> '
				 		    	+'<div class="ub-f1">${views}</div>'
								+'<div class="umh2 umw2 ub-img5 im5 lpicl lpic"></div>'
				 		    	+'${lastpost}'
				 		   +' </div>'
				 		+'</div> '
						+'<div class="res8 lis-sw ub-img4"></div>  '   
				 	+'</li><li class="ubt1"></li>';
		}
		var res = zy_tmpl(tmpl,list,length,j2vCb);
		
		if(json.zywy_curpage) curpage = int(json.zywy_curpage);
		if(json.zywy_totalpage) totpage = int(json.zywy_totalpage);
		
       	if(curpage==1)
       	{
       		while(cContent.childElementCount>1)
       		{
       			cContent.removeChild(cContent.firstElementChild);
       		}
       	}
		if(!res) res='<div class="tx-c"><div class="umh1"></div><div>暂无帖子</div></div>';
		var node = document.createElement("ul");
		node.className = "b-gra c-gra uc-n";
		node.innerHTML = res;;
		cContent.insertBefore(node,cContent.lastElementChild);
	}
}
function j2vCb(d,c)
{
	var str = '';
	 if(c.length>1)
	 {
		switch(c[1])
		{
			case 'imgid':
				str = d.picid || d.aid;
				break;
		}
	 }
	 return str;
}

function go2new5(tid, uid){
	setstorage('params','{"tid":"'+tid+'", "uid":"'+uid+'"}');
	openwin('forum_detail','forum_detail.html','10');
}

</script>
</html>
